package com.gf.demo.rabbitmqdemo.mq;

import com.gf.demo.rabbitmqdemo.dto.BaseDto;
import com.gf.demo.rabbitmqdemo.dto.MqMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author gaofei
 * @date 2022/6/8 19:38
 */
@Component
@Slf4j
public class MqRecvTest {
    @RabbitListener(queues = "gaofeitest.queue1")
    @RabbitHandler
    public void recv(MqMessage message) {
        for (BaseDto baseDto : message.getBaseDtoList()) {
            log.info("数据类型:{} id{} time{} toString {}", baseDto.getClass().getName(), baseDto.getId(), baseDto.getTime(), baseDto);
        }
    }
}
